<?php include  APP_PATH.'../template/public/header.php'?>
<aside class="main-sidebar">
    <section class="sidebar">
        <?php include APP_PATH.'../template/public/navigation.php'?>
    </section>
</aside>
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            {$title}
            <a  data-toggle="modal" data-target="#myModal"  type="button" class="btn btn-sm btn-primary" >添加app自定义定向添加</a>
        </h1>

        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> {$title}</a></li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-body">

                <table id='table'
                       data-url="{:url('app_custom_list')}"
                       data-toggle="table"
                       data-show-refresh="true"
                       data-show-toggle="true"
                       data-show-columns="true"
                       data-search="true"
                       data-advanced-search="true"
                       data-side-pagination="server"
                       data-select-item-name="worker_picker"
                       data-show-export="true"
                       data-click-to-select="true"
                       data-toolbar="#toolbar"
                       data-sort-name="name"
                       data-sort-order="desc">
                    <div class="bars pull-left">
                        <div id="toolbar">
                        </div>
                    </div>
                    <thead>
                    <tr>
                        <th data-field="id"  data-align="left" data-sortable="true" >编号</th>
                        <th data-field="name"  data-align="left" data-sortable="true" >app定向名称</th>
                        <th data-field="operation"   data-align="left">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </section>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加app自定义定向
                    </h4>
                </div>
                <div class="modal-body">
                    <form id="form"  action="">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="exampleInputEmail1">app自定义定向名称</label>
                                <input name="name" type="text"  class="layui-input" id="exampleInputEmail1" >
                            </div>
                        </div>
                        <div class="box-footer">
                            <button  id="submit" class="btn btn-primary"  >添加</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        </div>

                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
<?php include APP_PATH.'../template/public/footer.php'; ?>
<script>
    function del_int(id) {
        var loading = layer.load(1, {shade: [0.1, '#fff']});
        $.get("{:url('del_appcus')}?id="+id,function (res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.get("{:url('app_custom_list')}", function(data){
                        layer.close(loading);
                        if(data.length == 0)
                        {
                            alert("页面数据为空,请选择其他项");
                            return ;
                        }
                        $('#table').bootstrapTable("load",data);
                    });
                });
            } else {
                layer.msg(res.msg, {time: 1800, icon: 2});
            }

        })
    }
    $('#submit').click(function () {
        var data = {};
        var t = $('#form').serializeArray();
        $.each(t, function () {
            data[this.name] = this.value;
        });
        console.log(data);
        var loading = layer.load(1, {shade: [0.1, '#fff']});
        $.post("{:url('')}", data, function (res) {
            layer.close(loading);
            if (res.code > 0) {
                layer.msg(res.msg, {time: 800, icon: 1}, function () {
                    location.href = res.url;
                });
            } else {
                layer.msg(res.msg, {time: 1800, icon: 2});
            }
        });
        return false;
    });
</script>
</html>